class Solution {
public:
    bool isPalindrome(string s) {
        if (s.size() == 1)
            return true;
        int start = 0, end = s.size() - 1;
        for (auto& i : s)
        {
            if (i >= 'A' && i <= 'Z')
            {
                i += 32;
            }
        }
        while (start < end)
        {
            while (start < end)
            {
                if (s[start] >= 'a' && s[start] <= 'z' || (s[start] >= '0' && s[start] <= '9'))
                {
                    break;
                }
                start++;
            }
            while (start < end)
            {
                if ((s[end] >= 'a' && s[end] <= 'z') || (s[end] >= '0' && s[end] <= '9'))
                {
                    break;
                }
                end--;
            }
            if (s[start++] != s[end--])
                return false;
        }
        return true;
    }
};